package cs2340.todolist.JUnit;

import org.junit.Test;

import cs2340.todolist.model.account_management.AccountManager;


public class TestAccountValidation {


	/**
	 * tests to make sure the password length is being checked correctly
	 */
	@Test
	public void testPasswordLength() {
		junit.framework.Assert.assertFalse("Short Message Was Allowed", AccountManager.checkPasswordLength("ts"));
		junit.framework.Assert.assertTrue("Minimum Message Was Not Allowed", AccountManager.checkPasswordLength("tsr"));
		junit.framework.Assert.assertTrue("Maximum Message Was Not Allowed", AccountManager.checkPasswordLength("01234567890123"));
		junit.framework.Assert.assertFalse("Long Message Was Allowed", AccountManager.checkPasswordLength("012345678901234"));
	}
	
	/**
	 * tests to make sure the username length is being checked correctly
	 */
	@Test
	public void testUsernameLength() {
		junit.framework.Assert.assertFalse("Short Message Was Allowed", AccountManager.checkUsernameLength("ts"));
		junit.framework.Assert.assertTrue("Minimum Message Was Not Allowed", AccountManager.checkUsernameLength("tsr"));
		junit.framework.Assert.assertTrue("Maximum Message Was Not Allowed", AccountManager.checkUsernameLength("01234567890123"));
		junit.framework.Assert.assertFalse("Long Message Was Allowed", AccountManager.checkUsernameLength("012345678901234"));
	}
	
	/**
	 * tests to make sure the email pattern is being checked correctly
	 */
	@Test
	public void testEmailPattern() {
		junit.framework.Assert.assertFalse("Invalid Email 1 Was Allowed", AccountManager.checkEmailPattern("asdf"));
		junit.framework.Assert.assertFalse("Invalid Email 2 Was Allowed", AccountManager.checkEmailPattern("@dfd.com"));
		junit.framework.Assert.assertFalse("Invalid Email 3 Was Allowed", AccountManager.checkEmailPattern("asdf@"));
		junit.framework.Assert.assertFalse("Invalid Email 4 Was Allowed", AccountManager.checkEmailPattern("@@sdf"));
		junit.framework.Assert.assertTrue("Valid Email 1 Was Not Allowed", AccountManager.checkEmailPattern("asdf@asdf.com"));
	}
	
	/**
	 * tests to make sure the passwords are being compared properly
	 */
	@Test
	public void testComparePassword() {
		junit.framework.Assert.assertFalse("Non similar passwords 1 allowed", AccountManager.comparePassword("test321", "test123"));
		junit.framework.Assert.assertFalse("Non similar passwords 2 allowed", AccountManager.comparePassword("TEST", "test"));
		junit.framework.Assert.assertFalse("Non similar passwords 3 allowed", AccountManager.comparePassword("test", "testing"));
		junit.framework.Assert.assertTrue("Similar passwords not allowed", AccountManager.comparePassword("test", "test"));
	}
		
}
